package com.yangrui.app.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "video")
public class eVideo {
    @Id
    private Integer id;
    @Field(type = FieldType.Text,analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String title;
    @Field(type = FieldType.Text)
    private String summary;
    @Field(type = FieldType.Text)
    @JsonProperty("cover-img")
    private String coverImg;
    @Field(type = FieldType.Text)
    private  Double price;
    @Field(type = FieldType.Text)
    private Double point;
    @Field(type = FieldType.Text)
    @JsonProperty("create-time")
    private Date createTime;
    @Field(type = FieldType.Text)
    private List<Chapter> chapters;

    public eVideo (Video video){
        this.id=video.getId();
        this.title=video.getTitle();
        this.summary=video.getSummary();
        this.coverImg=video.getCoverImg();
        this.price=video.getPrice();
        this.point=video.getPoint();
        this.createTime=video.getCreateTime();
        this.chapters=video.getChapters();
    }

}
